package cn.ekuma.epos.datalogic.define.dao.sale.kitchen;

import com.openbravo.bean.Product;
import com.openbravo.bean.sales.KitchenLineInfo;
import com.openbravo.bean.sales.Ticket;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

import cn.ekuma.data.dao.BaseDAO;

public class KitchenLineInfoDAO extends BaseDAO<KitchenLineInfo> {

	public KitchenLineInfoDAO(I_Session s) {
		super(s);
	}

	@Override
	public KitchenLineInfo readValues(DataRead dr,KitchenLineInfo obj) throws BasicException {
		if(obj==null)
			obj=new KitchenLineInfo();
		obj.setId(dr.getString(1));
		obj.setTicketId(dr.getString(2));
		obj.setTicketLineId(dr.getInt(3));
		obj.setProductid(dr.getString(4));
		obj.setAttsetinstid(dr.getString(5));
		
		obj.setMultiply(dr.getDouble(6));

		obj.setCreatDate(dr.getTimestamp(7));

		
		obj.setTicketState(dr.getInt(8));
		obj.setLineState(dr.getInt(9));
		obj.setTableName(dr.getString(10));
		obj.setUrgent(dr.getBoolean(11));
		obj.setLastModified(dr.getTimestamp(12));
		return obj;
	}

	
	
	
	@Override
	public Class getSuportClass() {
		return KitchenLineInfo.class;
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition(s,
                "KITCHEN_WORKLINE",
                new Field[]{
				     new Field("ID",Datas.STRING,Formats.STRING),
                     new Field("TICKET",Datas.STRING,Formats.STRING,Ticket.class),
                     new Field("LINE",Datas.INT,Formats.INT),
                     new Field("PRODUCT",Datas.STRING,Formats.STRING,Product.class),
                     new Field("ATTRIBUTESETINSTANCE_ID",Datas.STRING,Formats.STRING),
                     new Field("UNITS",Datas.DOUBLE,Formats.DOUBLE),

                     new Field("CURDATE",Datas.TIMESTAMP,Formats.TIMESTAMP),
                     
                     new Field("TICKETSTATE",Datas.INT,Formats.INT),
                     new Field("LINESTATE",Datas.INT,Formats.INT),
                     new Field("PLACE",Datas.STRING,Formats.STRING),
                     new Field("URGENT",Datas.BOOLEAN,Formats.BOOLEAN),
                     new Field("LASTMODIFIED",Datas.TIMESTAMP,Formats.TIMESTAMP)
                    },
                new int[]{0});
	}

	@Override
	public void writeInsertValues(DataWrite dp, KitchenLineInfo obj)
			throws BasicException {
		dp.setString(1,obj.getId());
		dp.setString(1,obj.getTicketId());
		dp.setInt(3,obj.getTicketLineId());
		dp.setString(4,obj.getProductid());
		dp.setString(5,obj.getAttsetinstid());
		
		dp.setDouble(6,obj.getMultiply());

		dp.setTimestamp(7,obj.getCreatDate());

		
		dp.setInt(8,obj.getTicketState());
		dp.setInt(9,obj.getLineState());
		dp.setString(10,obj.getTableName());
		dp.setBoolean(11,obj.isUrgent());
		dp.setTimestamp(12,obj.getLastModified());
		
	}

}
